from django.db import models

# Create your models here.
from django.db import models
from common.db import BaseModel
# Django中自带的用户认证模型
from django.contrib.auth.models import AbstractUser, Group, Permission


# Create your models here.

class User(AbstractUser, BaseModel):
    """
        用户模型
        AbstractUser中有id,username, password,email,is_active等，我们只需要定义
        mobile，avatar等即可
    """
    email = models.EmailField(verbose_name="邮箱", default='', max_length=30)
    mobile = models.CharField(verbose_name="手机号", default='', max_length=15)
    avatar = models.ImageField(verbose_name="用户头像", blank=True, null=True)
    groups = models.ManyToManyField(Group, blank=True, related_name="account_users")
    user_permissions = models.ManyToManyField(Permission, blank=True, related_name="account_users")

    class Meta:
        db_table = 'users'
        verbose_name = '用户表'
        # 避免后端表名加s
        verbose_name_plural = verbose_name

class VerifCode(models.Model):
    """验证码模型"""
    mobile = models.CharField(verbose_name='手机号码', max_length=11)
    code = models.CharField(max_length=6, verbose_name='验证码',)
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="生成时间")

    class Meta:
        db_table = 'verifcode'
        verbose_name = '验证码表'
        verbose_name_plural = verbose_name





